<?php

/**
 *	Entry name：项目名称
 *	Description：项目说明
 *	Author：ZERO-ART
 *	Author Url：http://www.lykep.com
 * 	Contact：708298599  656001878
 *	2019-11-07 15:16:44
 */

/**
 * 初始化采集器一
 * @param [string]  $url  [请求地址]
 * @param integer $red  [是否开启重定向 0关闭 1开启]
 * @param integer $time [请求等待时间]
 */
function LoadOne($_url, $_red = 1, $_time = 10)
{
    $user_agent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"; //UA
    $ch = curl_init(); //启动会话
    curl_setopt($ch, CURLOPT_HEADER, 0); //不返回 header 部分
    curl_setopt($ch, CURLOPT_URL, $_url); //访问地址
    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); // 伪造ua
    curl_setopt($ch, CURLOPT_REFERER, $_url); //伪装请求来源 URL
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //参数为1表示传输数据，为0表示直接输出显示
    $ip = mt_rand(48, 140) . "." . mt_rand(10, 240) . "." . mt_rand(10, 240) . "." . mt_rand(10, 240); //随机 ip
    $httpheader[] = 'CLIENT-IP:' . $ip;
    $httpheader[] = 'X-FORWARDED-FOR:' . $ip;
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader); //附加协议头
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $_red); //支持重定向
    curl_setopt($ch, CURLOPT_AUTOREFERER, $_red); //重定向时，自动设置header的Referer信息           
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证证书和hosts
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); // 从证书中检查SSL加密算法是否存在
    curl_setopt($ch, CURLOPT_TIMEOUT, $_time); //设置curl允许执行的最长秒数
    curl_setopt($ch, CURLOPT_ENCODING, ''); //解决网页乱码问题
    $content = trim(curl_exec($ch)); //移除两边空白或其他字符
    curl_close($ch); //关闭会话
    return $content; //返回数据
}

/**
 * 初始化请求地址
 * @param [string]  $obj [调用方法名]]
 * @param [array] 	$val [GET参数值]
 * @param [string] 	$url [请求地址]
 */
function InitUrl($obj, $val = [], $url = 'https://www.360kan.com/')
{
    //判断调用方法
    switch ($obj) {
        case 'getDyList': //获取360电影列表
            //请求参数拼接
            $v1 = 'dianying/list.php?year=' . $val['year'] . '&area=' . $val['area'] . '&act=all' . '&cat=' . $val['cat'] . '&rank=' . $val['rank'] . '&pageno=' . $val['page'];
            break;
        case 'getDsList': //获取360电视列表
            //请求参数拼接
            $v1 = 'dianshi/list.php?year=' . $val['year'] . '&area=' . $val['area'] . '&act=all' . '&cat=' . $val['cat'] . '&rank=' . $val['rank'] . '&pageno=' . $val['page'];
            break;
        case 'getDmList': //获取360动漫列表
            //请求参数拼接
            $v1 = 'dongman/list.php?year=' . $val['year'] . '&area=' . $val['area'] . '&act=all' . '&cat=' . $val['cat'] . '&rank=' . $val['rank'] . '&pageno=' . $val['page'];
            break;
        case 'getZyList': //获取360综艺列表
            //请求参数拼接
            $v1 = 'zongyi/list.php?year=' . $val['year'] . '&area=' . $val['area'] . '&act=all' . '&cat=' . $val['cat'] . '&rank=' . $val['rank'] . '&pageno=' . $val['page'];
            break;

        default:
            $v1 = '';
            break;
    }

    //判断是否为空
    if (!empty($v1)) {
        //拼接地址
        $v2 = $url . $v1;
        //输出地址
        return $v2;
    } else {
        return;
    }
}

/**
 * 初始化返回数据
 */
function InitData()
{
    $data = [
        "code" => "200",
        "data" => [],
        "nav" => [],
        "col" => [],
        "page" => [],
        "type" => '',
        "consume" => 0
    ];
    return $data;
}

/**
 * 获取360电影列表
 * @param array  $_get 参数
 * @param int $num 输出影片数量 可为空 大于零生效
 */
function getDyList($_get = [], $_num = 0)
{


    //获取采集地址
    $_url = InitUrl("getDyList", $_get);
    //判断地址是否存在
    if (empty($_url)) {
        return;
    }
    $json_data = InitData();
    //获取网页源码
    $html = LoadOne($_url);
    //截取列表代码关键部分
    preg_match('/s-tab-main([\s\S]+?)s-common-body">/', $html, $ym);
    if (isset($ym[1])) { //判断指定数据是否存在
        //赋值一个新的变量
        $code = $ym[1];
        //截取每个影片关键数据
        preg_match_all('/<li class="item">([\s\S]+?)<\/li>/', $code, $li);

        //截取每个影片图片地址
        preg_match_all('/<img src="(.*?)">/', $code, $vod_pic);
        //截取每个影片详情地址
        preg_match_all('/<a class="js-tongjic" href="(.*?)">/', $code, $vod_url);
        //截取每个影片付费情况
        preg_match_all('/<span class="pay">(.*?)<\/span>/', $code, $vod_pay);
        //截取每个影片年代
        preg_match_all('/<span class="hint">(.*?)<\/span>/', $code, $vod_year);
        //截取每个影片评分
        preg_match_all('/<span class="point">(.*?)<\/span>/', $code, $vod_score);
        //截取每个影片标题
        preg_match_all('/<span class="s1">(.*?)<\/span>/', $code, $vod_title);
        //截取每个影片主演
        preg_match_all('/<p class="star">(.*?)<\/p>/', $code, $vod_actor);

        //获取到导航关键点
        preg_match('#data-block=\"tj-filter\"([\s\S]+?)class=\"js-tab-container\"#', $html, $code2); //截取导航关键点源码
        //获取到分页关键点
        preg_match('#js-ew-page([\s\S]+?)s-common-body#', $html, $code3); //截取导航关键点源码

        //状态
        $json_data['code'] = '200';

        //获取总计影片数
        $for = count($li[0]);
        if ($for > 0) {
            //判断自定义数量
            if ($_num > 0) {
                $for = $_num;
            }

            //遍历数据
            for ($i = 0; $i < $for; $i++) {
                $json_data['data'][$i]['vod_id'] = $i + 1; //编号
                $json_data['data'][$i]['vod_pic'] = isset($vod_pic[1][$i]) ? $vod_pic[1][$i] : ''; //图片
                $json_data['data'][$i]['vod_url'] = isset($vod_url[1][$i]) ? $vod_url[1][$i] : ''; //地址
                $json_data['data'][$i]['vod_pay'] = isset($vod_pay[1][$i]) ? $vod_pay[1][$i] : ''; //付费
                $json_data['data'][$i]['vod_year'] = isset($vod_year[1][$i]) ? $vod_year[1][$i] : ''; //年代
                $json_data['data'][$i]['vod_score'] = isset($vod_score[1][$i]) ? $vod_score[1][$i] : '0.0'; //评分
                $json_data['data'][$i]['vod_hint'] =  ''; //更新集数

                $json_data['data'][$i]['vod_title'] = isset($vod_title[1][$i]) ? $vod_title[1][$i] : ''; //标题
                $json_data['data'][$i]['vod_actor'] = isset($vod_actor[1][$i]) ? $vod_actor[1][$i] : ''; //主演
            }
        }

        //导航
        if (isset($code2[1])) {
            //类型
            preg_match('#<dt class="type">类型([\s\S]+?)<\/dd>#', $code2[1], $nav_lx); //截取类型源码
            preg_match('#<dt class="type">年代([\s\S]+?)<\/dd>#', $code2[1], $nav_nd); //截取年代源码
            preg_match('#<dt class="type">地区([\s\S]+?)<\/dd>#', $code2[1], $nav_dq); //截取地区源码
            preg_match('#<dt class="type">明星([\s\S]+?)<\/dd>#', $code2[1], $nav_mx); //截取明星源码
            $_val_lx = isset($nav_lxnav_lx[1])?$nav_lxnav_lx[1]:"";
            $nav_lxdat = str_ireplace('<i class="s-hot-icon"></i>', ' ', $_val_lx); //删除多余字符串
            preg_match_all('#<a class="js-tongjip" href="([\s\S]+?)cat=([\s\S]+?)" target="_self" monitor([\s\S]+?)>([\s\S]+?)<\/a>#', $nav_lxdat, $vod_lx); //类型
            preg_match_all('#<a class="js-tongjip" href="([\s\S]+?)year=([\s\S]+?)" target="_self" monitor([\s\S]+?)>([\s\S]+?)<\/a>#', $nav_nd[1], $vod_nd); //年代
            preg_match_all('#<a class="js-tongjip" href="([\s\S]+?)area=([\s\S]+?)" target="_self" monitor([\s\S]+?)>([\s\S]+?)<\/a>#', $nav_dq[1], $vod_dq); //地区
            preg_match_all('#<a class="js-tongjip" href="([\s\S]+?)act=([\s\S]+?)" target="_self" monitor([\s\S]+?)>([\s\S]+?)<\/a>#', $nav_mx[1], $vod_mx); //明星
            //类型名称
            preg_match_all('#<dt class="type">(.*)</dt>#', $code2[1], $nav_type);
            $numtype = count($nav_type[1]);
            for ($i = 0; $i < $numtype; $i++) {
                $json_data['nav'][$i]['name'] = "按" . $nav_type[1][$i]; //类型名称

                //类型
                $numlx = count($vod_lx[2]) + 1;
                $json_data['nav'][0]['data'][0]['id'] = 'all';
                $json_data['nav'][0]['data'][0]['name'] = '全部';
                for ($a1 = 1; $a1 < $numlx; $a1++) {
                    $json_data['nav'][0]['data'][$a1]['id'] = $vod_lx[2][$a1 - 1]; //类型ID
                    $json_data['nav'][0]['data'][$a1]['name'] = trim($vod_lx[4][$a1 - 1]); //类型名称
                }

                //年代 
                $numnd = count($vod_nd[2]) + 1;
                $json_data['nav'][1]['data'][0]['id'] = 'all';
                $json_data['nav'][1]['data'][0]['name'] = '全部';
                for ($a2 = 1; $a2 < $numnd; $a2++) {
                    $json_data['nav'][1]['data'][$a2]['id'] = trim($vod_nd[2][$a2 - 1]); //明星
                    $json_data['nav'][1]['data'][$a2]['name'] = trim($vod_nd[4][$a2 - 1]); //明星名称
                }

                //地区
                $numdq = count($vod_dq[2]) + 1;
                $json_data['nav'][2]['data'][0]['id'] = 'all';
                $json_data['nav'][2]['data'][0]['name'] = '全部';
                for ($a3 = 1; $a3 < $numdq; $a3++) {
                    $json_data['nav'][2]['data'][$a3]['id'] = $vod_dq[2][$a3 - 1]; //类型ID
                    $json_data['nav'][2]['data'][$a3]['name'] = trim($vod_dq[4][$a3 - 1]); //类型名称
                }

                //明星
                $nummx = count($vod_mx[2]) + 1;
                $json_data['nav'][3]['data'][0]['id'] = 'all';
                $json_data['nav'][3]['data'][0]['name'] = '全部';
                for ($a4 = 1; $a4 < $nummx; $a4++) {
                    $json_data['nav'][3]['data'][$a4]['id'] = trim($vod_mx[2][$a4 - 1]); //明星
                    $json_data['nav'][3]['data'][$a4]['name'] = trim($vod_mx[2][$a4 - 1]); //明星名称
                }
            }

            //去重
            $json_data['nav'][0]['data'] = array_unique($json_data['nav'][0]['data'], SORT_REGULAR);
            $json_data['nav'][1]['data'] = array_unique($json_data['nav'][1]['data'], SORT_REGULAR);
            $json_data['nav'][2]['data'] = array_unique($json_data['nav'][2]['data'], SORT_REGULAR);
            $json_data['nav'][3]['data'] = array_unique($json_data['nav'][3]['data'], SORT_REGULAR);
        }
        $col_v1 = [['id' => 'rankhot', 'name' => '最近热映'], ['id' => 'createtime', 'name' => '最近上映'], ['id' => 'rankpoint', 'name' => '最受好评']];
        //专题
        $json_data['col'] = $col_v1;
        //分页总数
        if (isset($code3[1])) {
            preg_match_all('#<a href=\'(.*)\' target=\'_self\' monitor(.*?)>(.*)</a>#', $code3[1], $page_v1);
            if (isset($page_v1[3])) {
                foreach ($page_v1[3] as $key => $value) {
                    $page = $value;
                }
            }
        }
        //页面信息
        $json_data['page'] = [
            'pageindex' => $_get['page'],
            "pagecount" => floor(isset($page) ? $page : '0'),
            "pagesize" => $for,
        ];
        //类型
        $json_data['type'] = ["id" => $_get['vt'], "title" => '电影列表'];
        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间
        //输出影片json数据
        return json_encode($json_data);
    } else {
        //状态
        $json_data['code'] = '404'; //404数据为空
        $json_data['data'] = [];
        $json_data['nav'] = [];
        $json_data['col'] = [];
        //页面信息
        $json_data['page'] = [
            'pageindex' => $_get['page'],
            "pagecount" =>  '0',
            "pagesize" => 0,
        ];
        //类型
        $json_data['type'] = ["id" => $_get['vt'], "title" => '电影列表'];
        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间
        return json_encode($json_data);
    }
}


/**
 * 获取360电视列表
 * @param [type]  $url [电视列表地址]
 * @param integer $num [输出影片数量 可为空 大于零生效]
 */
function getDsList($_get, $_num = 0)
{


    //获取采集地址
    $_url = InitUrl("getDsList", $_get);
    //判断地址是否存在
    if (empty($_url)) {
        return;
    }
    $json_data = InitData();
    //获取网页源码
    $html = LoadOne($_url);
    //截取列表代码关键部分
    preg_match('/s-tab-main([\s\S]+?)s-common-body">/', $html, $ym);
    if (isset($ym[1])) { //判断指定数据是否存在
        //赋值一个新的变量
        $code = $ym[1];
        //截取每个影片关键数据
        preg_match_all('/<li class="item">([\s\S]+?)<\/li>/', $code, $li);
        //截取每个影片图片地址
        preg_match_all('/<img src="(.*?)">/', $code, $vod_pic);
        //截取每个影片详情地址
        preg_match_all('/<a class="js-tongjic" href="(.*?)">/', $code, $vod_url);
        //截取每个影片更新集数
        preg_match_all('/<span class="hint">(.*?)<\/span>/', $code, $vod_hint);
        //截取每个影片标题
        preg_match_all('/<span class="s1">(.*?)<\/span>/', $code, $vod_title);
        //截取每个影片主演
        preg_match_all('/<p class="star">(.*?)<\/p>/', $code, $vod_actor);

        //获取到导航关键点	
        preg_match('#data-block=\"tj-filter\"([\s\S]+?)class=\"js-tab-container\"#', $html, $code2); //截取导航关键点源码

        //获取到分页关键点
        preg_match('#js-ew-page([\s\S]+?)s-common-body#', $html, $code3); //截取导航关键点源码

        //状态
        $json_data['code'] = '200';

        //获取总计影片数
        $for = count($li[0]);
        if ($for > 0) {
            //判断自定义数量
            if ($_num > 0) {
                $for = $_num;
            }

            //遍历数据
            for ($i = 0; $i < $for; $i++) {
                $json_data['data'][$i]['vod_id'] = $i + 1; //编号
                $json_data['data'][$i]['vod_pic'] = isset($vod_pic[1][$i]) ? $vod_pic[1][$i] : ''; //图片
                $json_data['data'][$i]['vod_url'] = isset($vod_url[1][$i]) ? $vod_url[1][$i] : ''; //地址

                $json_data['data'][$i]['vod_pay'] =  ''; //付费
                $json_data['data'][$i]['vod_year'] =  ''; //年代
                $json_data['data'][$i]['vod_score'] = '0.0'; //评分

                $json_data['data'][$i]['vod_hint'] = isset($vod_hint[1][$i]) ? $vod_hint[1][$i] : ''; //更新集数
                $json_data['data'][$i]['vod_title'] = isset($vod_title[1][$i]) ? $vod_title[1][$i] : ''; //标题
                $json_data['data'][$i]['vod_actor'] = isset($vod_actor[1][$i]) ? $vod_actor[1][$i] : ''; //主演
            }
        }

        //导航
        if (isset($code2[1])) {
            //类型
            preg_match('#<dt class="type">类型([\s\S]+?)<\/dd>#', $code2[1], $nav_lx); //截取类型源码
            preg_match('#<dt class="type">年代([\s\S]+?)<\/dd>#', $code2[1], $nav_nd); //截取年代源码
            preg_match('#<dt class="type">地区([\s\S]+?)<\/dd>#', $code2[1], $nav_dq); //截取地区源码
            preg_match('#<dt class="type">明星([\s\S]+?)<\/dd>#', $code2[1], $nav_mx); //截取明星源码
            $_val_lx = isset($nav_lxnav_lx[1])?$nav_lxnav_lx[1]:"";
            $nav_lxdat = str_ireplace('<i class="s-hot-icon"></i>', ' ',$_val_lx); //删除多余字符串

            preg_match_all('#<a class="js-tongjip" href="([\s\S]+?)cat=([\s\S]+?)" target="_self" monitor([\s\S]+?)>([\s\S]+?)<\/a>#', $nav_lxdat, $vod_lx); //类型
            preg_match_all('#<a class="js-tongjip" href="([\s\S]+?)year=([\s\S]+?)" target="_self" monitor([\s\S]+?)>([\s\S]+?)<\/a>#', $nav_nd[1], $vod_nd); //年代
            preg_match_all('#<a class="js-tongjip" href="([\s\S]+?)area=([\s\S]+?)" target="_self" monitor([\s\S]+?)>([\s\S]+?)<\/a>#', $nav_dq[1], $vod_dq); //地区
            preg_match_all('#<a class="js-tongjip" href="([\s\S]+?)act=([\s\S]+?)" target="_self" monitor([\s\S]+?)>([\s\S]+?)<\/a>#', $nav_mx[1], $vod_mx); //明星

            preg_match_all('#<dt class="type">(.*)</dt>#', $code2[1], $nav_type);
            $numtype = count($nav_type[1]);
            for ($a1 = 0; $a1 < $numtype; $a1++) {
                $json_data['nav'][$a1]['name'] = "按" . $nav_type[1][$a1]; //类型名称

                //类型
                $numlx = count($vod_lx[2]) + 1;
                $json_data['nav'][0]['data'][0]['id'] = 'all';
                $json_data['nav'][0]['data'][0]['name'] = '全部';
                for ($i = 1; $i < $numlx; $i++) {
                    $json_data['nav'][0]['data'][$i]['id'] = $vod_lx[2][$i - 1]; //类型ID
                    $json_data['nav'][0]['data'][$i]['name'] = trim($vod_lx[4][$i - 1]); //类型名称
                }

                //年代
                $numlx = count($vod_nd[2]) + 1;
                $json_data['nav'][1]['data'][0]['id'] = 'all';
                $json_data['nav'][1]['data'][0]['name'] = 'all';
                for ($i = 1; $i < $numlx; $i++) {
                    $json_data['nav'][1]['data'][$i]['id'] = $vod_nd[2][$i - 1]; //年代
                    $json_data['nav'][1]['data'][$i]['name'] = $vod_nd[2][$i - 1]; //年代
                }

                //地区
                $numdq = count($vod_dq[2]) + 1;
                $json_data['nav'][2]['data'][0]['id'] = 'all';
                $json_data['nav'][2]['data'][0]['name'] = '全部';
                for ($i = 1; $i < $numdq; $i++) {
                    $json_data['nav'][2]['data'][$i]['id'] = $vod_dq[2][$i - 1]; //类型ID
                    $json_data['nav'][2]['data'][$i]['name'] = trim($vod_dq[4][$i - 1]); //类型名称
                }

                // 明星
                $json_data['nav'][3]['data'][0]['id'] = 'all';
                $json_data['nav'][3]['data'][0]['name'] = '全部';
                foreach ($vod_mx[2] as $key => $value) {
                    $json_data['nav'][3]['data'][$key]['id'] = trim($value); //明星
                    $json_data['nav'][3]['data'][$key]['name'] = trim($value); //明星
                }
            }

            //去重
            $json_data['nav'][0]['data'] = array_unique($json_data['nav'][0]['data'], SORT_REGULAR);
            $json_data['nav'][1]['data'] = array_unique($json_data['nav'][1]['data'], SORT_REGULAR);
            $json_data['nav'][2]['data'] = array_unique($json_data['nav'][2]['data'], SORT_REGULAR);
            $json_data['nav'][3]['data'] = array_unique($json_data['nav'][3]['data'], SORT_REGULAR);
            $json_data['nav'][1]['data'][0]['name'] = '全部';
        }

        $col_v1 = [['id' => 'rankhot', 'name' => '最近热映'],  ['id' => 'rankpoint', 'name' => '最受好评']];
        //专题
        $json_data['col'] = $col_v1;
        //分页总数
        if (isset($code3[1])) {
            preg_match_all('#<a href=\'(.*)\' target=\'_self\' monitor(.*?)>(.*)</a>#', $code3[1], $page_v1);
            if (isset($page_v1[3])) {
                foreach ($page_v1[3] as $key => $value) {
                    $page = $value;
                }
            }
        }
        //页面信息
        $json_data['page'] = [
            'pageindex' => $_get['page'],
            "pagecount" => floor(isset($page) ? $page : '0'),
            "pagesize" => $for,
        ];
        //类型
        $json_data['type'] = ["id" => $_get['vt'], "title" => '电视列表'];
        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间
        //输出影片json数据
        return json_encode($json_data);
    } else {
        //状态
        $json_data['code'] = '404'; //404数据为空
        $json_data['data'] = [];
        $json_data['nav'] = [];
        $json_data['col'] = [];
        //页面信息
        $json_data['page'] = [
            'pageindex' => $_get['page'],
            "pagecount" => '0',
            "pagesize" => 0,
        ];
        //类型
        $json_data['type'] = ["id" => $_get['vt'], "title" => '电视列表'];
        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间
        return json_encode($json_data);
    }
}


/**
 * 获取360动漫列表
 * @param array  $_get 参数
 * @param int $num 输出影片数量 可为空 大于零生效
 */
function getDmList($_get, $_num = 0)
{


    //获取采集地址
    $_url = InitUrl("getDmList", $_get);
    //判断地址是否存在
    if (empty($_url)) {
        return;
    }
    $json_data = InitData();
    //获取网页源码
    $html = LoadOne($_url);
    //截取列表代码关键部分
    preg_match('/s-tab-main([\s\S]+?)s-common-body">/', $html, $ym);
    if (isset($ym[1])) { //判断指定数据是否存在
        //赋值一个新的变量
        $code = $ym[1];
        //截取每个影片关键数据
        preg_match_all('/<li class="item">([\s\S]+?)<\/li>/', $code, $li);
        //截取每个影片图片地址
        preg_match_all('/<img src="(.*?)">/', $code, $vod_pic);
        //截取每个影片详情地址
        preg_match_all('/<a class="js-tongjic" href="(.*?)">/', $code, $vod_url);
        //截取每个影片更新集数
        preg_match_all('/<span class="hint">(.*?)<\/span>/', $code, $vod_hint);
        //截取每个影片标题
        preg_match_all('/<span class="s1">(.*?)<\/span>/', $code, $vod_title);

        //获取到导航关键点
        preg_match('#data-block=\"tj-filter\"([\s\S]+?)class=\"js-tab-container\"#', $html, $code2); //截取导航关键点源码

        //获取到分页关键点
        preg_match('#js-ew-page([\s\S]+?)s-common-body#', $html, $code3); //截取导航关键点源码

        //状态
        $json_data['code'] = '200';

        //获取总计影片数
        $for = count($li[0]);
        if ($for > 0) {
            //判断自定义数量
            if ($_num > 0) {
                $for = $_num;
            }

            //遍历数据
            for ($i = 0; $i < $for; $i++) {
                $json_data['data'][$i]['vod_id'] = $i + 1; //编号
                $json_data['data'][$i]['vod_pic'] = isset($vod_pic[1][$i]) ? $vod_pic[1][$i] : ''; //图片
                $json_data['data'][$i]['vod_url'] = isset($vod_url[1][$i]) ? $vod_url[1][$i] : ''; //地址

                $json_data['data'][$i]['vod_pay'] = ''; //付费
                $json_data['data'][$i]['vod_year'] = ''; //年代
                $json_data['data'][$i]['vod_score'] =  '0.0'; //评分

                $json_data['data'][$i]['vod_hint'] = isset($vod_hint[1][$i]) ? $vod_hint[1][$i] : ''; //更新集数
                $json_data['data'][$i]['vod_title'] = isset($vod_title[1][$i]) ? $vod_title[1][$i] : ''; //标题
                $json_data['data'][$i]['vod_actor'] =  ''; //主演
            }
        }

        //导航
        if (isset($code2[1])) {
            //类型
            preg_match('#<dt class="type">类型([\s\S]+?)<\/dd>#', $code2[1], $nav_lx); //截取类型源码
            preg_match('#<dt class="type">年代([\s\S]+?)<\/dd>#', $code2[1], $nav_nd); //截取年代源码
            preg_match('#<dt class="type">地区([\s\S]+?)<\/dd>#', $code2[1], $nav_dq); //截取地区源码
            $_val_lx = isset($nav_lxnav_lx[1])?$nav_lxnav_lx[1]:"";
            $nav_lxdat = str_ireplace('<i class="s-hot-icon"></i>', ' ', $_val_lx); //删除多余字符串

            preg_match_all('#<a class="js-tongjip" href="([\s\S]+?)cat=([\s\S]+?)" target="_self" monitor([\s\S]+?)>([\s\S]+?)<\/a>#', $nav_lxdat, $vod_lx); //类型
            preg_match_all('#<a class="js-tongjip" href="([\s\S]+?)year=([\s\S]+?)" target="_self" monitor([\s\S]+?)>([\s\S]+?)<\/a>#', $nav_nd[1], $vod_nd); //年代
            preg_match_all('#<a class="js-tongjip" href="([\s\S]+?)area=([\s\S]+?)" target="_self" monitor([\s\S]+?)>([\s\S]+?)<\/a>#', $nav_dq[1], $vod_dq); //地区

            //类型名称
            preg_match_all('#<dt class="type">(.*)</dt>#', $code2[1], $nav_type);

            $numtype = count($nav_type[1]);
            for ($a1 = 0; $a1 < $numtype; $a1++) {
                $json_data['nav'][$a1]['name'] = "按" . $nav_type[1][$a1]; //类型名称

                //类型
                $numlx = count($vod_lx[2]) + 1;
                $json_data['nav'][0]['data'][0]['id'] = 'all';
                $json_data['nav'][0]['data'][0]['name'] = '全部';
                for ($i = 1; $i < $numlx; $i++) {
                    $json_data['nav'][0]['data'][$i]['id'] = $vod_lx[2][$i - 1]; //类型ID
                    $json_data['nav'][0]['data'][$i]['name'] = trim($vod_lx[4][$i - 1]); //类型名称
                }

                //年代 
                $numnd = count($vod_nd[2]) + 1;
                $json_data['nav'][1]['data'][0]['id'] = 'all';
                $json_data['nav'][1]['data'][0]['name'] = '全部';
                for ($a2 = 1; $a2 < $numnd; $a2++) {
                    $json_data['nav'][1]['data'][$a2]['id'] = trim($vod_nd[2][$a2 - 1]); //明星
                    $json_data['nav'][1]['data'][$a2]['name'] = trim($vod_nd[4][$a2 - 1]); //明星名称
                }

                //地区
                $numdq = count($vod_dq[2]) + 1;
                $json_data['nav'][2]['data'][0]['id'] = 'all';
                $json_data['nav'][2]['data'][0]['name'] = '全部';
                for ($a3 = 1; $a3 < $numdq; $a3++) {
                    $json_data['nav'][2]['data'][$a3]['id'] = $vod_dq[2][$a3 - 1]; //类型ID
                    $json_data['nav'][2]['data'][$a3]['name'] = trim($vod_dq[4][$a3 - 1]); //类型名称
                }
            }
            //去重
            $json_data['nav'][0]['data'] = array_unique($json_data['nav'][0]['data'], SORT_REGULAR);
            $json_data['nav'][1]['data'] = array_unique($json_data['nav'][1]['data'], SORT_REGULAR);
            $json_data['nav'][2]['data'] = array_unique($json_data['nav'][2]['data'], SORT_REGULAR);
        }

        $col_v1 = [['id' => 'rankhot', 'name' => '最近热映'], ['id' => 'createtime', 'name' => '最近上映']];
        //专题
        $json_data['col'] = $col_v1;
        //分页总数
        if (isset($code3[1])) {
            preg_match_all('#<a href=\'(.*)\' target=\'_self\' monitor(.*?)>(.*)</a>#', $code3[1], $page_v1);
            if (isset($page_v1[3])) {
                foreach ($page_v1[3] as $key => $value) {
                    $page = $value;
                }
            }
        }
        //页面信息
        $json_data['page'] = [
            'pageindex' => $_get['page'],
            "pagecount" => floor(isset($page) ? $page : '0'),
            "pagesize" => $for,
        ];

        //类型
        $json_data['type'] = ["id" => $_get['vt'], "title" => '动漫列表'];
        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间
        //输出影片json数据
        return json_encode($json_data);
    } else {
        //状态
        $json_data['code'] = '404'; //404数据为空
        $json_data['data'] = [];
        $json_data['nav'] = [];
        $json_data['col'] = [];
        //页面信息
        $json_data['page'] = [
            'pageindex' => $_get['page'],
            "pagecount" =>  '0',
            "pagesize" => 0,
        ];
        //类型
        $json_data['type'] = ["id" => $_get['vt'], "title" => '动漫列表'];
        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间
        return json_encode($json_data);
    }
}


/**
 * 获取360综艺列表
 * @param array  $_get 参数
 * @param int $num 输出影片数量 可为空 大于零生效
 */
function getZyList($_get, $_num = 0)
{


    //获取采集地址
    $_url = InitUrl("getZyList", $_get);
    //判断地址是否存在
    if (empty($_url)) {
        return;
    }
    $json_data = InitData();
    //获取网页源码
    $html = LoadOne($_url);
    //截取列表代码关键部分
    preg_match('/s-tab-main([\s\S]+?)s-common-body">/', $html, $ym);
    if (isset($ym[1])) { //判断指定数据是否存在
        //赋值一个新的变量
        $code = $ym[1];
        //截取每个影片关键数据
        preg_match_all('/<li class="item">([\s\S]+?)<\/li>/', $code, $li);
        //截取每个影片图片地址
        preg_match_all('/<img src="(.*?)">/', $code, $vod_pic);
        //截取每个影片详情地址
        preg_match_all('/<a class="js-tongjic" href="(.*?)">/', $code, $vod_url);
        //截取每个影片更新集数
        preg_match_all('/<span class="hint">(.*?)<\/span>/', $code, $vod_hint);
        //截取每个影片标题
        preg_match_all('/<span class="s1">(.*?)<\/span>/', $code, $vod_title);
        //截取每个影片主演
        preg_match_all('/<p class="star">(.*?)<\/p>/', $code, $vod_actor);

        //获取到导航关键点
        preg_match('#data-block=\"tj-filter\"([\s\S]+?)class=\"js-tab-container\"#', $html, $code2); //截取导航关键点源码

        //获取到分页关键点
        preg_match('#js-ew-page([\s\S]+?)s-common-body#', $html, $code3); //截取导航关键点源码

        //状态
        $json_data['code'] = '200';

        //获取总计影片数
        $for = count($li[0]);
        if ($for > 0) {
            //判断自定义数量
            if ($_num > 0) {
                $for = $_num;
            }

            //遍历数据
            for ($i = 0; $i < $for; $i++) {
                $json_data['data'][$i]['vod_id'] = $i + 1; //编号
                $json_data['data'][$i]['vod_pic'] = isset($vod_pic[1][$i]) ? $vod_pic[1][$i] : ''; //图片
                $json_data['data'][$i]['vod_url'] = isset($vod_url[1][$i]) ? $vod_url[1][$i] : ''; //地址

                $json_data['data'][$i]['vod_pay'] =  ''; //付费
                $json_data['data'][$i]['vod_year'] = ''; //年代
                $json_data['data'][$i]['vod_score'] =  '0.0'; //评分

                $json_data['data'][$i]['vod_hint'] = isset($vod_hint[1][$i]) ? $vod_hint[1][$i] : ''; //更新集数
                $json_data['data'][$i]['vod_title'] = isset($vod_title[1][$i]) ? $vod_title[1][$i] : ''; //标题
                $json_data['data'][$i]['vod_actor'] = isset($vod_actor[1][$i]) ? $vod_actor[1][$i] : ''; //主演
            }
        }

        //导航
        if (isset($code2[1])) {
            //类型
            preg_match('#<dt class="type">类型([\s\S]+?)<\/dd>#', $code2[1], $nav_lx); //截取类型源码
            preg_match('#<dt class="type">地区([\s\S]+?)<\/dd>#', $code2[1], $nav_dq); //截取地区源码
            preg_match('#<dt class="type">明星([\s\S]+?)<\/dd>#', $code2[1], $nav_mx); //截取明星源码
            $_val_lx = isset($nav_lxnav_lx[1])?$nav_lxnav_lx[1]:"";
            $nav_lxdat = str_ireplace('<i class="s-hot-icon"></i>', ' ', $_val_lx); //删除多余字符串

            preg_match_all('#<a class="js-tongjip" href="([\s\S]+?)cat=([\s\S]+?)" target="_self" monitor([\s\S]+?)>([\s\S]+?)<\/a>#', $nav_lxdat, $vod_lx); //类型
            preg_match_all('#<a class="js-tongjip" href="([\s\S]+?)area=([\s\S]+?)" target="_self" monitor([\s\S]+?)>([\s\S]+?)<\/a>#', $nav_dq[1], $vod_dq); //地区
            preg_match_all('#<a class="js-tongjip" href="([\s\S]+?)act=([\s\S]+?)" target="_self" monitor([\s\S]+?)>([\s\S]+?)<\/a>#', $nav_mx[1], $vod_mx); //明星

            //类型名称
            preg_match_all('#<dt class="type">(.*)</dt>#', $code2[1], $nav_type);

            $numtype = count($nav_type[1]);
            for ($a1 = 0; $a1 < $numtype; $a1++) {
                $json_data['nav'][$a1]['name'] = "按" . $nav_type[1][$a1]; //类型名称

                //类型
                $numlx = count($vod_lx[2]) + 1;
                $json_data['nav'][0]['data'][0]['id'] = 'all';
                $json_data['nav'][0]['data'][0]['name'] = '全部';
                for ($i = 1; $i < $numlx; $i++) {
                    $json_data['nav'][0]['data'][$i]['id'] = $vod_lx[2][$i - 1]; //类型ID
                    $json_data['nav'][0]['data'][$i]['name'] = trim($vod_lx[4][$i - 1]); //类型名称
                }

                //明星
                $nummx = count($vod_mx[2]) + 1;
                $json_data['nav'][1]['data'][0]['id'] = 'all';
                $json_data['nav'][1]['data'][0]['name'] = '全部';
                for ($a4 = 1; $a4 < $nummx; $a4++) {
                    $json_data['nav'][1]['data'][$a4]['id'] = trim($vod_mx[2][$a4 - 1]); //明星
                    $json_data['nav'][1]['data'][$a4]['name'] = trim($vod_mx[2][$a4 - 1]); //明星名称
                }

                //地区
                $numdq = count($vod_dq[2]) + 1;
                $json_data['nav'][2]['data'][0]['id'] = 'all';
                $json_data['nav'][2]['data'][0]['name'] = '全部';
                for ($a3 = 1; $a3 < $numdq; $a3++) {
                    $json_data['nav'][2]['data'][$a3]['id'] = $vod_dq[2][$a3 - 1]; //类型ID
                    $json_data['nav'][2]['data'][$a3]['name'] = trim($vod_dq[4][$a3 - 1]); //类型名称
                }
            }

            //去重
            $json_data['nav'][0]['data'] = array_unique($json_data['nav'][0]['data'], SORT_REGULAR);
            $json_data['nav'][1]['data'] = array_unique($json_data['nav'][1]['data'], SORT_REGULAR);
            $json_data['nav'][2]['data'] = array_unique($json_data['nav'][2]['data'], SORT_REGULAR);

            //去掉明星
            $json_data['nav'][1]['data'] = [];
        }

        $col_v1 = [['id' => 'rankhot', 'name' => '最近热映'], ['id' => 'createtime', 'name' => '最近上映']];
        //专题
        $json_data['col'] = $col_v1;
        //分页总数
        if (isset($code3[1])) {
            preg_match_all('#<a href=\'(.*)\' target=\'_self\' monitor(.*?)>(.*)</a>#', $code3[1], $page_v1);
            if (isset($page_v1[3])) {
                foreach ($page_v1[3] as $key => $value) {
                    $page = $value;
                }
            }
        }
        //页面信息
        $json_data['page'] = [
            'pageindex' => $_get['page'],
            "pagecount" => floor(isset($page) ? $page : '0'),
            "pagesize" => $for,
        ];

        //类型
        $json_data['type'] = ["id" => $_get['vt'], "title" => '综艺列表'];
        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间
        //输出影片json数据
        return json_encode($json_data);
    } else {
        //状态
        $json_data['code'] = '404'; //404数据为空
        $json_data['data'] = [];
        $json_data['nav'] = [];
        $json_data['col'] = [];
        //页面信息
        $json_data['page'] = [
            'pageindex' => $_get['page'],
            "pagecount" =>  '0',
            "pagesize" => 0,
        ];
        //类型
        $json_data['type'] = ["id" => $_get['vt'], "title" => '综艺列表'];
        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间
        return json_encode($json_data);
    }
}

/**
 * 360影视搜索列表
 * @param string $_wd 搜索内容
 */
function getSoList($_wd)
{
    $url = 'https://so.360kan.com/index.php?from=&du=100&fr=147&pb=100&cat=0&st=100&pageno=1&kw=' . $_wd;
    $html = LoadOne($url);
    preg_match("#<i class=\"m-sanjiao\"></i>([\s\S]+?)<div class=\"p-body-right\">#", $html, $ym); //截取关键点

    if (isset($ym[1])) { //判断指定数据是否存在
        $code = $ym[1];
        preg_match_all('/<div class=\"m-mainpic\">([\s\S]+?)<div class=\"m-description\">/', $code, $li); //单条数据
        preg_match_all('#<img src=\"(.*?)\" alt=\"(.*?)\" />#', $code, $vod_pic); //海报/影片名 ·
        preg_match_all('/<span class=\"playtype\">(.*?)·(.*?)<\/span>/', $code, $vod_hint); //类型/年代
        preg_match_all('#<div class="m-score">(.*?)</div>#', $code, $vod_score); //评分
        preg_match_all('#<a href="http://www.360kan.com/(.*?)" class="g-playicon js-playicon"[\s\S]+?>#', $code, $vod_url); //地址
        preg_match_all('#<em class="vipicon">(.*?)</em>#', $code, $vod_pay); //付费
        preg_match_all('#m-description([\s\S]+?)<\/i>([\s\S]+?)<\/p>#', $code, $vod_deta); //简介
        // dd($vod_url);

        $numli = count($li[0]);

        $json_data['code'] = '200';
        $json_data['search']  = $_wd;
        for ($i = 0; $i < $numli; $i++) {
            preg_match_all('#<a  href="(.*?)" title="(.*?)" target="_self">(.*?)</a>#', $li[0][$i], $vod_actor); //主演
            $json_data['data'][$i]['id'] = $i + 1;
            $json_data['data'][$i]['vod_pic'] = isset($vod_pic[1][$i]) ? $vod_pic[1][$i] : ''; //图片
            $json_data['data'][$i]['vod_title'] = isset($vod_pic[2][$i]) ? $vod_pic[2][$i] : ''; //标题
            $json_data['data'][$i]['vod_type'] = isset($vod_hint[1][$i]) ? $vod_hint[1][$i] : ''; //电影类型

            $json_data['data'][$i]['vod_year'] = isset($vod_hint[2][$i]) ? $vod_hint[2][$i] : ''; //年代
            $json_data['data'][$i]['vod_score'] = isset($vod_score[1][$i]) ? $vod_score[1][$i] : ''; //评分
            $json_data['data'][$i]['vod_url'] = isset($vod_url[1][$i]) ? $vod_url[1][$i] : ''; //地址
            $vodtypeid = substr($json_data['data'][$i]['vod_url'], 0, 2);
            $vodtypeid = str_ireplace('/', '', $vodtypeid);
            $json_data['data'][$i]['vod_type_id'] = optConvert($vodtypeid); //电影类型标识
            $json_data['data'][$i]['vod_pay'] = isset($vod_pay[1][$i]) ? $vod_pay[1][$i] : ''; //付费
            $voddatajj = isset($vod_deta[2][$i]) ? $vod_deta[2][$i] : '';
            $vod_deta[2][$i] = str_replace("<p>", "", $voddatajj);
            $vod_deta[2][$i] = str_replace("展开更多", "", $vod_deta[2][$i]);
            $vod_deta[2][$i] = str_replace("&gt;", "", $vod_deta[2][$i]);
            $json_data['data'][$i]['vod_desc'] = strip_tags(isset($vod_deta[2][$i]) ? $vod_deta[2][$i] : ''); //简介
            $numact = count($vod_actor[3]);
            for ($n = 0; $n < $numact; $n++) {
                $json_data['data'][$i]['vod_actor'][$n] = isset($vod_actor[3][$n]) ? $vod_actor[3][$n] : ''; //主演
            }
        }
        $json_data['number'] = $numli;
        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间
        //输出JSON数据
        return json_encode($json_data);
    } else {

        //状态
        $json_data['code'] = '204'; //204数据为空
        $json_data['search']  = $_wd;
        //数量
        $json_data['number'] = '0';
        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间

        return json_encode($json_data);
    }
}

###########################详情分割线########################################

/**
 * 获取电影信息详情
 * @param [string] $_md5 [电影参数]
 * @param string $_url [地址]
 */
function getDydeta($_md5, $_url = 'https://www.360kan.com/')
{
    $url = $_url . $_md5['type'] . '/' . $_md5['sign'] . '.html';
    //获取网页源码
    $html = LoadOne($url);
    //截取代码关键部分
    preg_match('/"c-top"([\s\S]+?)c-body g-clear/', $html, $ym);
    if (isset($ym[1])) { //判断指定数据是否存在
        //赋值一个新的变量
        $code = $ym[1];
        //截取影片图片地址
        preg_match('#<img src=\"(.*?)\">#', $code, $vod_pic); //海报
        //截取影片名称
        preg_match('#<h1>(.*?)<\/h1>#', $code, $vod_title); //名称
        //截取影片年代
        preg_match('#>年代 ：</span>(.*?)<\/p>#', $code, $vod_year); //年代
        //截取影片地区
        preg_match('#>地区 ：</span>(.*?)<\/p>#', $code, $vod_region); //地区
        //全网电影排名
        preg_match('#全网电影排名第(.*?)名#', $code, $vod_ranking); //排名
        //截取影片评分
        preg_match('#<span class="s">(.*?)<\/span><#', $code, $vod_score); //评分
        //截取影片类型
        preg_match_all('# <a class="cat(.*?)target="_blank">(.*?)</a>#', $code, $vod_type); //类型
        //截取影片主演
        preg_match_all('#<a class="name"(.*?)">(.*?)</a>#', $code, $vod_actor); //主演
        //截取影片简介
        preg_match_all('#<p class="item-desc">(.*?)<\/p><\/div>#', $code, $vod_deta); //简介
        //截取影片//标识/地址/名称
        preg_match_all('#<a data-daochu="to=(.*?)" class="(.*?)" href="(.*?)">(.*?)<\/a>#', $code, $vod_url); //标识/地址/名称

        // 推荐
        preg_match_all('#<img src="(.*)" data-src=\'(.*)\'>#', $html, $c_img); //c图片
        preg_match_all('#<a href=\'/(.*)\' data-index=(.*) title="(.*)">#', $html, $c_url); //c地址//名称



        $json_data['code'] = '200'; //状态
        $json_data['data']['playListType'] = 1; //列表类型
        $json_data['data']['playerType'] =  '2'; //播放器类型
        //判断是否截取到播放地址
        if (isset($vod_url[1])) {
            $numurl = count($vod_url[1]); //获取匹配数量
            for ($i = 0; $i < $numurl; $i++) {
                $json_data['data']['play'][$i]['vod_sign'] = isset($vod_url[1][$i]) ? $vod_url[1][$i] : ''; //标识
                $json_data['data']['play'][$i]['vod_name'] = isset($vod_url[4][$i]) ? $vod_url[4][$i] : ''; //标题
                $json_data['data']['play'][$i]['vip'] = ''; //vip

                $json_data['data']['play'][$i]['data'][0]['vod_sign'] = isset($vod_url[1][$i]) ? $vod_url[1][$i] : ''; //标识
                $json_data['data']['play'][$i]['data'][0]['vod_url'] = isset($vod_url[3][$i]) ? $vod_url[3][$i] : ''; //地址
                $json_data['data']['play'][$i]['data'][0]['vod_name'] = isset($vod_url[4][$i]) ? $vod_url[4][$i] : ''; //名称
                $json_data['data']['play'][$i]['data'][0]['vod_time'] = ''; //期
            }
            $json_data['data']['cid'] = isset($_md5['sign']) ? $_md5['sign'] : ''; //id
            $json_data['data']['cat'] =  ''; //cat
        }

        $json_data['data']['id'] = $_md5; //参数
        $json_data['data']['vod_pic'] = isset($vod_pic[1]) ? $vod_pic[1] : ''; //海报
        $json_data['data']['vod_title'] = isset($vod_title[1]) ? $vod_title[1] : '';; //标题
        $json_data['data']['vod_year'] = isset($vod_year[1]) ? $vod_year[1] : '';; //年代
        $json_data['data']['vod_region'] = isset($vod_region[1]) ? $vod_region[1] : '';; //地区
        $json_data['data']['vod_ranking'] = isset($vod_ranking[1]) ? $vod_ranking[1] : '';; //排名
        $json_data['data']['vod_score'] = isset($vod_score[1]) ? $vod_score[1] : '';; //评分

        $numtype = count($vod_type); //得到类型数量
        //循环遍历类型
        for ($i = 0; $i < $numtype; $i++) {
            $json_data['data']['vod_type'][$i] = isset($vod_type[2][$i]) ? $vod_type[2][$i] : ''; //类型
        }

        $numactor = count($vod_actor); //得到演员数量
        //循环遍历演员
        for ($i = 1; $i < $numactor; $i++) {
            $json_data['data']['vod_actor'][$i] = isset($vod_actor[2][$i]) ? $vod_actor[2][$i] : ''; //演员
        }

        $json_data['data']['vod_director'] = isset($vod_actor[2][0]) ? $vod_actor[2][0] : ''; //导演

        $voddatajj = isset($vod_deta[1][0]) ? $vod_deta[1][0] : '';
        $voddatajj = str_replace("</a>", "", $voddatajj);
        $voddatajj = str_replace('<a href="#" class="js-open btn">', "", $voddatajj);
        $voddatajj = str_replace("展开更多", "", $voddatajj);
        $voddatajj = str_replace("&gt;", "", $voddatajj);
        $json_data['data']['vod_desc'] = strip_tags(isset($voddatajj) ? $voddatajj : ''); //简介

        //猜你喜欢数据
        for ($i = 0; $i < count($c_img[1]); $i++) {
            $json_data['data']['recommend'][$i]['vod_img'] = $c_img[2][$i];
            $json_data['data']['recommend'][$i]['vod_url'] = $c_url[1][$i];
            $json_data['data']['recommend'][$i]['vod_name'] = $c_url[3][$i];
        }

        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间
        return json_encode($json_data);
    } else {
        //状态
        $json_data['code'] = '404'; //204数据为空
        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间
        return json_encode($json_data);
    }
}


/**
 * 获取电视信息详情
 * @param [string] $_md5 [电视参数]
 * @param string $_url [地址]
 */
function getDsdeta($_md5, $_url = 'https://www.360kan.com/')
{
    // $url = $_url . $_md5 . '.html';
    $url = $_url . $_md5['type'] . '/' . $_md5['sign'] . '.html';
    //获取网页源码
    $html = LoadOne($url);
    //截取代码关键部分
    preg_match('/"c-top"([\s\S]+?)c-body g-clear/', $html, $ym);
    if (isset($ym[1])) { //判断指定数据是否存在
        //赋值一个新的变量
        $code = $ym[1];
        //截取影片图片地址
        preg_match('#<img src=\"(.*?)\">#', $code, $vod_pic); //海报
        //截取影片名称
        preg_match('#<h1>(.*?)<\/h1>#', $code, $vod_title); //名称
        //截取影片年代
        preg_match('#>年代 ：</span>(.*?)<\/p>#', $code, $vod_year); //年代
        //截取影片地区
        preg_match('#>地区 ：</span>(.*?)<\/p>#', $code, $vod_region); //地区
        //全网电影排名
        preg_match('#全网电视剧排名第(.*?)名#', $code, $vod_ranking); //排名
        //截取影片评分
        preg_match('#<span class="s">(.*?)<\/span><#', $code, $vod_score); //评分
        //截取影片类型
        preg_match_all('# <a class="cat(.*?)target="_blank">(.*?)</a>#', $code, $vod_type); //类型
        //截取影片主演
        preg_match_all('#<a class="name"(.*?)">(.*?)</a>#', $code, $vod_actor); //主演
        //截取影片简介
        preg_match_all('#none;"><span>简介 ：<\/span><p class="item-desc">(.*?)<a href=#', $code, $vod_deta); //简介

        //截取资源来源代码
        preg_match('#use_monitor_v2([\s\S]+?)};#', $html, $vod_info); //资源代码

        // 推荐
        preg_match_all('#<img src="(.*)" data-src=\'(.*)\'>#', $html, $c_img); //c图片
        preg_match_all('#<a href=\'/(.*)\' data-index=(.*) title="(.*)">#', $html, $c_url); //c地址//名称

        $json_data['code'] = '200'; //状态
        $json_data['data']['playListType'] = 2; //列表类型
        $json_data['data']['playerType'] =  '2'; //播放器类型
        if (isset($vod_info[1])) {
            preg_match('#id: \'(.*)\',#', $vod_info[1], $vod_cid_id); //id
            preg_match('#cat: \'(.*)\',#', $vod_info[1], $vod_cid_cat); //cat
            preg_match('#playsite:(.*)],#', $vod_info[1], $vod_cid_dat); //标识/标题/vip
            if (isset($vod_cid_dat[1])) {
                $cid_dat = $vod_cid_dat[1] . ']';
                $vod_cid_data = json_decode($cid_dat, true);
                foreach ($vod_cid_data as $k => $v) {
                    $json_data['data']['play'][$k]['vod_sign'] = isset($v['ensite']) ? $v['ensite'] : ''; //标识
                    $json_data['data']['play'][$k]['vod_name'] = isset($v['cnsite']) ? $v['cnsite'] : ''; //标题
                    $json_data['data']['play'][$k]['vip'] = isset($v['vip']) ? $v['vip'] : ''; //vip
                    $json_data['data']['play'][$k]['data'] = getDsPlay($v['ensite'], $vod_cid_id[1]);
                }
            }
            $json_data['data']['cid'] = isset($vod_cid_id[1]) ? $vod_cid_id[1] : ''; //id
            $json_data['data']['cat'] = isset($vod_cid_cat[1]) ? $vod_cid_cat[1] : ''; //cat
        }


        $json_data['data']['id'] = $_md5; //参数
        $json_data['data']['vod_pic'] = isset($vod_pic[1]) ? $vod_pic[1] : ''; //海报
        $json_data['data']['vod_title'] = isset($vod_title[1]) ? $vod_title[1] : '';; //标题
        $json_data['data']['vod_year'] = isset($vod_year[1]) ? $vod_year[1] : '';; //年代
        $json_data['data']['vod_region'] = isset($vod_region[1]) ? $vod_region[1] : '';; //地区
        $json_data['data']['vod_ranking'] = isset($vod_ranking[1]) ? $vod_ranking[1] : '';; //排名
        $json_data['data']['vod_score'] = isset($vod_score[1]) ? $vod_score[1] : '';; //评分





        $numtype = count($vod_type); //得到类型数量
        //循环遍历类型
        for ($i = 0; $i < $numtype; $i++) {
            $json_data['data']['vod_type'][$i] = isset($vod_type[2][$i]) ? $vod_type[2][$i] : ''; //类型
        }

        $numactor = count($vod_actor[2]); //得到演员数量
        //循环遍历演员
        for ($i = 1; $i < $numactor; $i++) {
            $json_data['data']['vod_actor'][$i] = isset($vod_actor[2][$i]) ? $vod_actor[2][$i] : ''; //演员
        }

        $json_data['data']['vod_director'] = isset($vod_actor[2][0]) ? $vod_actor[2][0] : ''; //导演

        $voddatajj = isset($vod_deta[1][0]) ? $vod_deta[1][0] : '';
        $voddatajj = str_replace("</a>", "", $voddatajj);
        $voddatajj = str_replace('<a href="#" class="js-open btn">', "", $voddatajj);
        $voddatajj = str_replace("展开更多", "", $voddatajj);
        $voddatajj = str_replace("&gt;", "", $voddatajj);
        $json_data['data']['vod_desc'] = strip_tags(isset($voddatajj) ? $voddatajj : ''); //简介

        //猜你喜欢数据
        for ($i = 0; $i < count($c_img[1]); $i++) {
            $json_data['data']['recommend'][$i]['vod_img'] = $c_img[2][$i];
            $json_data['data']['recommend'][$i]['vod_url'] = $c_url[1][$i];
            $json_data['data']['recommend'][$i]['vod_name'] = $c_url[3][$i];
        }

        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间
        return json_encode($json_data);
    } else {
        //设置返回状态
        //header("HTTP/1.1 204 No content");
        //状态
        $json_data['code'] = '404'; //204数据为空

        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间

        return json_encode($json_data);
    }
}


/**
 * 获取综艺信息详情
 * @param [string] $_md5 [综艺参数]
 * @param string $_url [地址]
 */
function getZydeta($_md5, $_url = 'https://www.360kan.com/')
{
    // $url = $_url . $_md5 . '.html';
    $url = $_url . $_md5['type'] . '/' . $_md5['sign'] . '.html';
    //获取网页源码
    $html = LoadOne($url);
    //截取代码关键部分
    preg_match('/"c-top"([\s\S]+?)c-body g-clear/', $html, $ym);
    if (isset($ym[1])) { //判断指定数据是否存在
        //赋值一个新的变量
        $code = $ym[1];
        //截取影片图片地址
        preg_match('#<img src=\"(.*?)\">#', $code, $vod_pic); //海报
        //截取影片名称
        preg_match('#<h1>(.*?)<\/h1>#', $code, $vod_title); //名称
        //截取更新信息 
        preg_match('#<p class="tag">(.*?)<\/p>#', $code, $vod_hint); //更新
        //截取播出来源 
        preg_match('#<span>播出 ：<\/span>(.*?)<\/p>#', $code, $vod_form); //播出
        //截取影片年代
        preg_match('#>年代 ：</span>(.*?)<\/p>#', $code, $vod_year); //年代
        //截取影片地区
        preg_match('#>地区 ：</span>(.*?)<\/p>#', $code, $vod_region); //地区
        //全网电影排名
        preg_match('#全网综艺排名第(.*?)名#', $code, $vod_ranking); //排名
        //截取影片评分
        preg_match('#<span class="s">(.*?)<\/span><#', $code, $vod_score); //评分
        //截取影片类型
        preg_match_all('# <a class="cat(.*?)target="_blank">(.*?)</a>#', $code, $vod_type); //类型
        //截取影片主演
        preg_match_all('#<a class="name"(.*?)">(.*?)</a>#', $code, $vod_actor); //主演
        //截取影片简介
        preg_match_all('#none;"><span>简介 ：<\/span><p class="item-desc">(.*?)<a href=#', $code, $vod_deta); //简介
        //截取播放地址代码
        preg_match('#g-clear js-month-page([\s\S]+?)c-body g-clear#', $html, $vod_urldat); //播放地址代码

        // 推荐
        preg_match_all('#<img src="(.*)" data-src=\'(.*)\'>#', $html, $c_img); //c图片
        preg_match_all('#<a href=\'/(.*)\' data-index=(.*) title="(.*)">#', $html, $c_url); //c地址//名称

        $json_data['code'] = '200'; //状态
        $json_data['data']['playListType'] = 3; //列表类型
        $json_data['data']['playerType'] =  '2'; //播放器类型
        if (isset($vod_urldat[1])) {
            //截取每一期
            preg_match_all('#<li ([\s\S]+?)<\/a><\/li>#', $vod_urldat[1], $li); //每一期
            $numli = count($li[1]);
            $num_i = 0;
            while ($num_i < $numli) {
                $x = $num_i;
                preg_match('#data-daochu=to=(.*?) class#', $li[0][$x], $vod2_bs); //标识
                preg_match('#href=\'(.*?)\' data#', $li[0][$x], $vod2_url); //地址
                preg_match_all('#title=\'(.*?)\' class=#', $li[0][$x], $vod2_names); //名称
                preg_match('#hint\'>(.*?)<\/span>#', $li[0][$x], $vod2_time); //期
                preg_match('#<span class="ea-site([\s\S]+?)>(.*?)<\/span>#', $html, $vod2_name); // 来源
                $p_name = isset($vod2_names[1][0]) ? $vod2_names[1][0] : '无播放源'; //名称

                $json_data['data']['play'][0]['vod_sign'] = isset($vod2_bs[1]) ? $vod2_bs[1] : ''; //标识
                $json_data['data']['play'][0]['vod_name'] =  isset($vod2_name[2]) ? $vod2_name[2] : '';  //标题
                $json_data['data']['play'][0]['vip'] = ''; //vip

                $json_data['data']['play'][0]['data'][$x]['vod_sign'] = isset($vod2_bs[1]) ? $vod2_bs[1] : ''; //标识
                $json_data['data']['play'][0]['data'][$x]['vod_url'] = isset($vod2_url[1]) ? $vod2_url[1] : ''; //地址
                $json_data['data']['play'][0]['data'][$x]['vod_name'] = $p_name; //名称
                $json_data['data']['play'][0]['data'][$x]['vod_time'] = isset($vod2_time[1]) ? $vod2_time[1] : ''; //期
                $num_i++;
            }
            // for ($x=0; $x < $numli; $x++) {
            // 	preg_match('#data-daochu=to=(.*?) class#',$li[0][$x],$vod_bs);//标识
            // 	preg_match('#href=\'(.*?)\' data#',$li[0][$x],$vod_url);//地址
            // 	preg_match('#title=\'(.*?)\' class=#',$li[0][$x],$vod_names);//名称
            // 	preg_match('#hint\'>(.*?)<\/span>#',$li[0][$x],$vod_time);//期
            // 	$p_name = isset($vod_names[1])?$vod_names[1]:'无播放源';//名称

            // 	$json_data['data']['play'][$x]['dy_sign']=isset($vod_bs[1])?$vod_bs[1]:'';//标识
            // 	$json_data['data']['play'][$x]['dy_url']=isset($vod_url[1])?$vod_url[1]:'';//地址
            // 	$json_data['data']['play'][$x]['dy_name']=$p_name;
            // 	$json_data['data']['play'][$x]['dy_time']=isset($vod_time[1])?$vod_time[1]:'';//期
            // 	$json_data['data']['num'] = $numli;//数量	
            // }				
        }


        $json_data['data']['id'] = $_md5; //参数
        $json_data['data']['vod_pic'] = isset($vod_pic[1]) ? $vod_pic[1] : ''; //海报
        $json_data['data']['vod_title'] = isset($vod_title[1]) ? $vod_title[1] : '';; //标题
        $json_data['data']['vod_vod_hint'] = isset($vod_hint[1]) ? $vod_hint[1] : '';; //更新
        $json_data['data']['vod_year'] = isset($vod_year[1]) ? $vod_year[1] : '';; //年代
        $json_data['data']['vod_region'] = isset($vod_region[1]) ? $vod_region[1] : '';; //地区
        $json_data['data']['vod_ranking'] = isset($vod_ranking[1]) ? $vod_ranking[1] : '';; //排名
        $json_data['data']['vod_score'] = isset($vod_score[1]) ? $vod_score[1] : '';; //评分


        //判断是否截取到播放地址
        // if (isset($vod_url[1])) {
        // 	$numurl = count($vod_url[1]); //获取匹配数量
        // 	for ($i = 0; $i < $numurl; $i++) {
        // 		$json_data['data']['play'][$i]['dy_sign'] = isset($vod_url[2][$i]) ? $vod_url[2][$i] : ''; //标识
        // 		$json_data['data']['play'][$i]['dy_url'] = isset($vod_url[3][$i]) ? $vod_url[3][$i] : ''; //地址
        // 		$json_data['data']['play'][$i]['dy_name'] = isset($vod_url[1][$i]) ? $vod_url[1][$i] : '无播放源'; //名称
        // 	}
        // 	$json_data['data']['num'] = $numurl; //数量	
        // }


        $numtype = count($vod_type); //得到类型数量
        //循环遍历类型
        for ($i = 0; $i < $numtype; $i++) {
            $json_data['data']['vod_type'][$i] = isset($vod_type[2][$i]) ? $vod_type[2][$i] : ''; //类型
        }

        $numactor = count($vod_actor[2]); //得到演员数量
        //循环遍历演员
        for ($i = 1; $i < $numactor; $i++) {
            $json_data['data']['vod_actor'][$i] = isset($vod_actor[2][$i]) ? $vod_actor[2][$i] : ''; //演员
        }

        $json_data['data']['vod_director'] = isset($vod_form[1]) ? $vod_form[1] : ''; //播出

        $voddatajj = isset($vod_deta[1][0]) ? $vod_deta[1][0] : '';
        $voddatajj = str_replace("</a>", "", $voddatajj);
        $voddatajj = str_replace('<a href="#" class="js-open btn">', "", $voddatajj);
        $voddatajj = str_replace("展开更多", "", $voddatajj);
        $voddatajj = str_replace("&gt;", "", $voddatajj);
        $json_data['data']['vod_desc'] = strip_tags(isset($voddatajj) ? $voddatajj : ''); //简介

        //猜你喜欢数据
        for ($i = 0; $i < count($c_img[1]); $i++) {
            $json_data['data']['recommend'][$i]['vod_img'] = $c_img[2][$i];
            $json_data['data']['recommend'][$i]['vod_url'] = $c_url[1][$i];
            $json_data['data']['recommend'][$i]['vod_name'] = $c_url[3][$i];
        }


        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间

        return json_encode($json_data);
    } else {
        //设置返回状态
        //header("HTTP/1.1 204 No content");
        //状态
        $json_data['code'] = '204'; //204数据为空
        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间
        return json_encode($json_data);
    }
}


/**
 * 获取动漫信息详情
 * @param [string] $_md5 [动漫参数]
 * @param string $_url [地址]
 */
function getDmdeta($_md5, $_url = 'https://www.360kan.com/')
{
    // $url = $_url . $_md5 . '.html';
    $url = $_url . $_md5['type'] . '/' . $_md5['sign'] . '.html';

    //获取网页源码
    $html = LoadOne($url);
    //截取代码关键部分
    preg_match('/"c-top"([\s\S]+?)c-body g-clear/', $html, $ym);
    if (isset($ym[1])) { //判断指定数据是否存在
        //赋值一个新的变量
        $code = $ym[1];
        //截取影片图片地址
        preg_match('#<img src=\"(.*?)\">#', $code, $vod_pic); //海报
        //截取影片名称
        preg_match('#<h1>(.*?)<\/h1>#', $code, $vod_title); //名称
        //截取影片年代
        preg_match('#>年代 ：</span>(.*?)<\/p>#', $code, $vod_year); //年代
        //截取影片地区
        preg_match('#>地区 ：</span>(.*?)<\/p>#', $code, $vod_region); //地区
        //全网电影排名
        preg_match('#全网电视剧排名第(.*?)名#', $code, $vod_ranking); //排名
        //截取影片评分
        preg_match('#<span class="s">(.*?)<\/span><#', $code, $vod_score); //评分
        //截取影片类型
        preg_match_all('# <a class="cat(.*?)target="_blank">(.*?)</a>#', $code, $vod_type); //类型
        //截取影片主演
        preg_match_all('#<a class="name"(.*?)">(.*?)</a>#', $code, $vod_actor); //主演
        //截取影片简介
        preg_match_all('#none;"><span>简介 ：<\/span><p class="item-desc">(.*?)<a href=#', $code, $vod_deta); //简介
        //截取资源来源代码
        preg_match('#use_monitor_v2([\s\S]+?)};#', $html, $vod_info); //资源代码

        // 推荐
        preg_match_all('#<img src="(.*)" data-src=\'(.*)\'>#', $html, $c_img); //c图片
        preg_match_all('#<a href=\'/(.*)\' data-index=(.*) title="(.*)">#', $html, $c_url); //c地址//名称
        preg_match_all('#<a href=\'/(.*)\' target#', $html, $c_urls); //c地址
        preg_match_all('#<p class=\'title\'><span>(.*)</span></p>#', $html, $c_title); //名称

        //js-series-all m-series-number-container
        if (strpos($html, 'js-series-all m-series-number-container') !== false) {
            //截取播放地址代码
            preg_match('#js-series-all m-series-number-container([\s\S]+?)<\/div><\/div><\/div>#', $code, $vod_urldat); //播放地址代码	
        } else {
            //截取播放地址代码
            preg_match('#m-series-content js-tab-content([\s\S]+?)<\/div>#', $code, $vod_urldat); //播放地址代码	
        }

        $json_data['code'] = '200'; //状态
        $json_data['data']['playListType'] = 2; //列表类型
        $json_data['data']['playerType'] =  '2'; //播放器类型
        if (isset($vod_info[1])) {
            preg_match('#id: \'(.*)\',#', $vod_info[1], $vod_cid_id); //id
            preg_match('#cat: \'(.*)\',#', $vod_info[1], $vod_cid_cat); //cat
            preg_match('#playsite:(.*)],#', $vod_info[1], $vod_cid_dat); //标识/标题/vip
            if (isset($vod_cid_dat[1])) {
                $cid_dat = $vod_cid_dat[1] . ']';
                $vod_cid_data = json_decode($cid_dat, true);
                foreach ($vod_cid_data as $k => $v) {
                    $json_data['data']['play'][$k]['vod_sign'] = isset($v['ensite']) ? $v['ensite'] : ''; //标识
                    $json_data['data']['play'][$k]['vod_name'] = isset($v['cnsite']) ? $v['cnsite'] : ''; //标题
                    $json_data['data']['play'][$k]['vip'] = isset($v['vip']) ? $v['vip'] : ''; //vip
                    $json_data['data']['play'][$k]['data'] = getDmPlay($v['ensite'], $vod_cid_id[1]);
                }
            }

            $json_data['cid']['id'] = isset($vod_cid_id[1]) ? $vod_cid_id[1] : ''; //id
            $json_data['cid']['cat'] = isset($vod_cid_cat[1]) ? $vod_cid_cat[1] : ''; //cat
        }

        $json_data['data']['id'] = $_md5; //参数
        $json_data['data']['vod_pic'] = isset($vod_pic[1]) ? $vod_pic[1] : ''; //海报
        $json_data['data']['vod_title'] = isset($vod_title[1]) ? $vod_title[1] : '';; //标题
        $json_data['data']['vod_year'] = isset($vod_year[1]) ? $vod_year[1] : '';; //年代
        $json_data['data']['vod_region'] = isset($vod_region[1]) ? $vod_region[1] : '';; //地区
        $json_data['data']['vod_ranking'] = isset($vod_ranking[1]) ? $vod_ranking[1] : '';; //排名
        $json_data['data']['vod_score'] = isset($vod_score[1]) ? $vod_score[1] : '';; //评分

        $numtype = count($vod_type); //得到类型数量
        //循环遍历类型
        for ($i = 0; $i < $numtype; $i++) {
            $json_data['data']['vod_type'][$i] = isset($vod_type[2][$i]) ? $vod_type[2][$i] : ''; //类型
        }

        $numactor = count($vod_actor[2]); //得到演员数量
        //循环遍历演员
        for ($i = 1; $i < $numactor; $i++) {
            $json_data['data']['vod_actor'][$i] = isset($vod_actor[2][$i]) ? $vod_actor[2][$i] : ''; //演员
        }

        $json_data['data']['vod_director'] = isset($vod_actor[2][0]) ? $vod_actor[2][0] : ''; //导演

        $voddatajj = isset($vod_deta[1][0]) ? $vod_deta[1][0] : '';
        $voddatajj = str_replace("</a>", "", $voddatajj);
        $voddatajj = str_replace('<a href="#" class="js-open btn">', "", $voddatajj);
        $voddatajj = str_replace("展开更多", "", $voddatajj);
        $voddatajj = str_replace("&gt;", "", $voddatajj);
        $json_data['data']['vod_desc'] = strip_tags(isset($voddatajj) ? $voddatajj : ''); //简介

        //猜你喜欢数据
        for ($i = 0; $i < count($c_img[1]); $i++) {
            $json_data['data']['recommend'][$i]['vod_img'] = $c_img[2][$i];
            if (isset($c_url[1][$i])) {
                $json_data['data']['recommend'][$i]['vod_url'] = isset($c_url[1][$i]) ? $c_url[1][$i] : "";
                $json_data['data']['recommend'][$i]['vod_name'] = isset($c_url[3][$i]) ? $c_url[3][$i] : "";
            } else {
                $json_data['data']['recommend'][$i]['vod_url'] = isset($c_urls[1][$i]) ? $c_urls[1][$i] : "";
                $json_data['data']['recommend'][$i]['vod_name'] = isset($c_title[1][$i]) ? $c_title[1][$i] : "";
            }
        }

        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间

        return json_encode($json_data);
    } else {

        //状态
        $json_data['code'] = '404'; //204数据为空

        $endtime = microtime(true);
        $json_data['consume'] = round($endtime - APP_RUN_STARTTIME, 3) . 's'; //页面消耗时间

        return json_encode($json_data);
    }
}

###########################电视播放数据分割线########################################

/**
 * 获取电视剧播放数据
 * @param [string] $_site [来源网站]
 * @param [string] $_id   [去掉.html的页面地址参数]
 */
function getDsPlay($_site, $_id)
{
    //https://www.360kan.com/cover/switchsitev2?site=qiyi&id=QblvaH7lSzPpN3&category=2
    $url = 'http://www.360kan.com/cover/switchsitev2?site=' . $_site . '&id=' . $_id . '&category=2'; //地址拼接
    //获取源码
    $html = LoadOne($url);
    //解析json
    $html = json_decode($html, true); //解析json
    //数组转字符串
    $html = implode("", $html); //数组转字符串
    //截取播放地址代码
    preg_match('#num-tab-main g-clear js-tab"([\s\S]+?)</div>#', $html, $vod_urldat); //播放地址代码	
    //判断关键代码
    if (isset($vod_urldat[1])) {
        //截取影片//标识/地址/名称
        preg_match_all('#<a data-num="(.*?)" data-daochu="to=(.*?)" href="(.*?)">([\s\S]+?)</a>#', $vod_urldat[1], $vod_url); //集数/标识/地址/名称
        //判断是否截取到播放地址
        if (isset($vod_url[1])) {
            $numurl = count($vod_url[1]); //获取匹配数量
            for ($i = 0; $i < $numurl; $i++) {
                $json_data[$i]['vod_sign'] = isset($vod_url[2][$i]) ? $vod_url[2][$i] : ''; //标识
                $json_data[$i]['vod_url'] = isset($vod_url[3][$i]) ? $vod_url[3][$i] : ''; //地址
                $json_data[$i]['vod_name'] = isset($vod_url[1][$i]) ? $vod_url[1][$i] : '无播放源'; //名称
                $json_data[$i]['vod_time'] = ''; //期
            }
        }
        return ($json_data);
    } else {
        return [];
    }
}


/**
 * 获取动漫剧播放数据
 * @param [string] $_site [来源网站]
 * @param [string] $_id   [去掉.html的页面地址参数]
 */
function getDmPlay($_site, $_id)
{
    $url = 'http://www.360kan.com/cover/switchsitev2?site=' . $_site . '&id=' . $_id . '&category=4'; //地址拼接
    //获取源码
    $html = LoadOne($url);
    //解析json
    $html = json_decode($html, true); //解析json
    //数组转字符串
    $html = implode("", $html); //数组转字符串
    //截取播放地址代码
    preg_match('#num-tab-main g-clear js-tab"([\s\S]+?)</div>#', $html, $vod_urldat); //播放地址代码	
    //检测代码关键位置
    if (strpos($html, 'js-series-all m-series-number-container') !== false) {
        //截取播放地址代码
        preg_match('#js-series-all m-series-number-container([\s\S]+?)<\/div><\/div><\/div>#', $html, $vod_urldat); //播放地址代码	
    } else {
        //截取播放地址代码
        preg_match('#m-series-content js-tab-content([\s\S]+?)<\/div>#', $html, $vod_urldat); //播放地址代码	
    }
    //判断播放代码是否存在
    if (isset($vod_urldat[1])) {
        //截取影片//标识/地址/名称
        preg_match_all('#<a data-num="(.*?)"data-daochu="to=(.*?)" href="(.*?)">(.*?)</a>#', $vod_urldat[1], $vod_url); //集数/标识/地址/名称

        //判断是否截取到播放地址
        if (isset($vod_url[1])) {
            $numurl = count($vod_url[1]); //获取匹配数量
            for ($i = 0; $i < $numurl; $i++) {
                $json_data[$i]['vod_sign'] = isset($vod_url[2][$i]) ? $vod_url[2][$i] : ''; //标识
                $json_data[$i]['vod_url'] = isset($vod_url[3][$i]) ? $vod_url[3][$i] : ''; //地址
                $json_data[$i]['vod_name'] = isset($vod_url[1][$i]) ? $vod_url[1][$i] : '无播放源'; //名称
                $json_data[$i]['vod_time'] = ''; //期
            }
        }
        return ($json_data);
    } else {
        return [];
    }
}


/**
 * 标识值转换
 * @param [string] $val 待转换值
 */
function optConvert($val)
{
    switch ($val) {
        case 'm':
            return 'dy';
            break;
        case 'tv':
            return 'tv';
            break;
        case 'ct':
            return 'dm';
            break;
        case 'va':
            return 'zy';
            break;
        default:
            return 'eq';
            break;
    }
}
